package com.xzkydz.modle;

import android.util.Log;

import com.xzkydz.app.MyApp;
import com.xzkydz.bean.RequestBgbhBean;
import com.xzkydz.bean.WaterPumpBean;
import com.xzkydz.utils.DateUtils;
import com.xzkydz.utils.Utils;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;

public class GetSign implements IGetSign {


    @Override
    public String getBgbhSign(RequestBgbhBean bean) {

        Map<String, Object> mp = new HashMap<String, Object>();  //传参map
        Map<String, String> params = new HashMap<String, String>();  //业务参数map去除sign
        Map<String, String> signMap = new HashMap<String, String>();  //签名map去除sign

        signMap.put("method", "getBgbh");
        signMap.put("appkey", bean.getAppkey());
        signMap.put("timestamp", DateUtils.dataFormat());
        mp.putAll(signMap);
        params.put("zjrName", bean.getParams().getZjrName());//主检人
        params.put("bglx", bean.getParams().getBglx()); //主排水泵的报告类型
        signMap.putAll(params);

        String sign = "";
        try {
            sign = Utils.buildSign(MyApp.getInstance().appKeyStr, signMap);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return sign;
    }


    @Override
    public String getUpdataSign(WaterPumpBean bean) {

        Map<String, String> params = new HashMap<String, String>();
        Map<String, String> signMap = new HashMap<String, String>();
        signMap.put("method", bean.getMethod());
        signMap.put("appkey", bean.getAppkey());
        signMap.put("timestamp", bean.getTimestamp());
        params.put("formName", bean.getParams().getFormName());
        params.put("bgbh", bean.getParams().getBgbh());
        signMap.putAll(params);

        String sign = "";
        try {
            sign = Utils.buildSign(MyApp.getInstance().appKeyStr, signMap);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return sign;
    }
}
